package com.demo.passenger.sys.user.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.passenger.sys.user.entity.SysUserRole;
import com.demo.passenger.sys.user.service.ISysUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author weifucheng
 * @since 2019-07-13
 */
@Controller
@RequestMapping("/sys/user/role")
public class SysUserRoleController {
    @Autowired
    ISysUserRoleService sysUserRoleService;

    @RequestMapping("/listByParams")
    @ResponseBody
    public List<SysUserRole> listByParams(Page<SysUserRole> page, SysUserRole sysUserRole){
        return sysUserRoleService.listByParams(page,sysUserRole);
    }

    @RequestMapping("/listAll")
    @ResponseBody
    public List<SysUserRole> listAll(){
        return sysUserRoleService.list();
    }

    @RequestMapping("/save")
    @ResponseBody
    public Boolean save(SysUserRole sysUserRole){
        return sysUserRoleService.saveOrUpdate(sysUserRole);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Boolean update(SysUserRole sysUserRole){
        return sysUserRoleService.saveOrUpdate(sysUserRole);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Boolean delete(SysUserRole sysUserRole){
        return sysUserRoleService.removeById(sysUserRole.getId());
    }
}
